package org.goyo.main.domain.dao;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;

import org.goyo.common.utils.Pager;
import org.goyo.main.domain.entity.BaseObject;
import org.goyo.main.domain.entity.system.SysUser;
import org.hibernate.Session;

public interface IBaseDAO {
	/**
	 * 鑾峰緱session
	 * @return
	 *//*
	public Session getSession();*/
	
	/**
	 * 鏍规嵁涓婚敭鑾峰緱瀵硅薄
	 * @param entityClass
	 * @param pk
	 * @return
	 */
	public <T> T get(Class<T> entityClass,Serializable pk);
	
	/**
	 * 鏍规嵁涓婚敭鑾峰緱瀵硅薄
	 * @param entityClass
	 * @param pk
	 * @return
	 */
	public <T> T load(Class<T> entityClass,Serializable pk);
	
	/**
	 * 鑾峰緱瀵硅薄鍏ㄩ儴璁板綍
	 * @param entityClass
	 * @return
	 */
	public <T> List<T> getAll(Class<T> entityClass);
	
	/**
	 * 鑾峰緱璁板綍鏉℃暟
	 * @param entityClass
	 * @return
	 */
	public <T> Long getTotalCount(Class<T> entityClass);
	
	/**
	 * 淇濆瓨瀵硅薄
	 * @param entity
	 * @return
	 */
	public <T> T save(Object entity);
	
	/**
	 * 淇濆瓨鎴栬�呮洿鏂板璞�
	 * @param entity
	 */
	public void saveOrUpdate(Object entity);

	/**
	 * 鏇存柊瀵硅薄
	 * @param entity
	 */
	public void update(Object entity);
	
	/**
	 * 鍒犻櫎瀵硅薄
	 * @param entity
	 */
	public void delete(Object entity);
	
	/**
	 * 鏍规嵁hql鏌ユ壘瀵硅薄锛岃繑鍥炲敮涓�鍊�
	 * @param hql
	 * @param params
	 * @return
	 */
	public <T> T findUnique(String hql,Object... params);
	
	/**
	 * 鏉′欢鍒嗛〉鍣�
	 * @param hql
	 * @param page
	 * @param params
	 * @return
	 */
	public <T> List<T> findObjects(String hql,Pager page,Object... params);
	
	/**
	 * 鍙傛暟璁板綍鏉℃暟
	 * @param hql
	 * @param params
	 * @return
	 */
	public int getTotalByCond(String hql,Object... params);
	
	
	/**
	 * 寮哄埗鍚屾
	 */
	public void flush();
	
	/**
	 * 鏍规嵁hql鍒犻櫎
	 * chenchuan
	 * @param hql
	 * @param params
	 * @return 鍒犻櫎鐨勮褰曟暟
	 */
	public int deleteByHql(String hql, Object[] params);
	
	/**
	 * 鏍规嵁hql鏇存柊
	 * chenchuan
	 * @param hql
	 * @param params
	 * @return 鍒犻櫎鐨勮褰曟暟
	 */
	public int updateByHql(String hql, Object[] params);
	
	/**
	 * 鎵归噺鍒犻櫎
	 * @param clazz
	 * @param fileName
	 * @param params
	 */
	public <T> void delBatch(Class<T> clazz,String fileName,Object[] params);
	
	/**
	 * 鎺掑簭
	 * @author chenchuan
	 * 2014骞�10鏈�23鏃�
	 */
	public String addSort(StringBuffer buf,Pager pager);
	
	/**
	 * 鏁版嵁杩囨护
	 * @param Filter
	 * @return
	 */
	public <T> String getFilterSql (Map<String, List<String>> filter );
	
	public <T> List<T> findByParams(Class<T> clazz,String fileName,Object[] params);
	
	public <T> BaseObject audit(Class<T> clazz,Object[] uuids);
	
	public <T> BaseObject unAudit(Class<T> clazz,Object[] uuids);
	
	public <T> BaseObject submit(Class<T> clazz,Object[] uuids);
	
	public <T> T findByUuid(Class<T> clazz,String uuid);
	
	/**
	 * 根据hql统计总数
	 * @param hql
	 * @return
	 */
	public Long countByHql(String hql);
	
	/**
	 * 执行sql
	 * @param sql
	 * @param parameters
	 * @return
	 */
	public Object executeSql(String sql,Object[] parameters);
	
	/**
	 * 根据sql查询然后返回转换为bean
	 * @param sql
	 * @param parameters
	 * @param Clazz
	 * @return
	 */
	public <T> List<T> findByHqlReNewObj(String hql,Object[] parameters,Class<T> Clazz);

	
}
